package com.example.projectjava.service;


import com.example.projectjava.dao.AddressDao;
import com.example.projectjava.dao.LogisticDao;
import com.example.projectjava.dao.ProductDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ProductService {
    @Autowired
    ProductDao productDao;//spring会自动将TrolleyDao注入到此类为(自动为该属性赋值)
    public List<Map<String,Object>> queryproduct(){
        return  productDao.queryAllproduct();
    }
    public  int productadd(int product_id,int category_id,String product_name,double price, //增
                           int stock){
       // String sql = "insert into product (product_id,category_id,product_name,price,stock) values(?,?,?,?,?)";
        return    productDao.productadd(product_id,category_id,product_name,price,stock);//返回了一个整数，用来表示此操作有没有成功
    }
    public int deleteproduct(int product_id){//删
        //String sql  = "DELETE from product where product_id=?";
        return  productDao.productdelete(product_id);
    }
    public  int  productupdate(String product_id,String category_id,String product_name,String price,String stock){//改
        //String sql = "update product set category_id=?,product_name=?,price=?,stock=? where product_id=?";
        return    productDao.productupdate(product_id,category_id,product_name,price,stock);
    }
    public  List<Map<String, Object>>  productquery(int product_id){ //查
       // String sql = "select * from product where product_id=?";
        return   productDao.productquery(product_id);}
}

